var columns = [{checkbox:true},
               {field:"id",title:"id",visible:false},
               {field:"companyCode",title:"公司编码"},
               {field:"companyName",title:"公司名称"},
              {field:"companySname",title:"公司简称"},
              {field:"companyNameEn",title:"公司英文名称"},
              {field:"adress",title:"地址"},
              {field:"addressEn",title:"英文地址"},
              {field:"fax",title:"传真"},
              {field:"email",title:"电子邮件"},
              
            
   		];
function queryParams(params) {
	var param = {
			pageNumber : params.pageNumber,
			pageSize : params.pageSize,
			"cname" :$('.search input').val()
		};
	return param;
}
var user_table = $('#user_table');//通过table id获取需要初始化的table
//初始化的table
initTable(user_table,$('#user_toolbar'),'company/list',columns,queryParams,'zh-CN',true);

//给搜索框添加提示
$('.search input').attr("placeholder","搜索公司编码/公司名称");

function resetPassword(){
	var ids = getSelections(user_table,'id');
    if (ids.length == 1) {
 	   loadPage('user/'+ids.toString()+'/toRestPassword');
    }else{
    	layer.msg("你没有选择行或选择了多行数据", {icon:0});
    }
}
function delUser(id){
	del("company/"+id+"/delete",search);
}

function btnDel(){
	var ids = getSelections(user_table,'id');
	if (ids.length==0) {
		layer.msg("请选择要删除的记录", {icon:0});
	}else{
		layer.confirm('确定删除所选记录？',{icon:3},function (index) {
			$.post('company/delete', {
        	    "json": JSON.stringify(ids)
        	},
        	function(json) {
        	    if (json.status == 0) {
        	    	refreshDelTable(user_table, ids.length);
        	    }
        	    layer.msg(json.message);
        	});
			layer.close(index);
		});
	}
}
function btnEdit(){
	var ids = getSelections(user_table,'id');
	if (ids.length == 1) {
	 	loadPage('company/'+ids.toString()+'/select');
	}else{
		layer.msg("你没有选择行或选择了多行数据", {icon:0});
	}
}